<?php
    require_once '/Controller/LoginController.php';
	require_once '/Model/LoginHandler.php';
	require_once '/View/LoginView.php';
	require_once '/Controller/RegisterController.php';
	require_once '/Model/RegisterHandler.php';
	require_once '/View/RegisterView.php';
	$title = "Labb2";
	$body = "";
	$lw = new LoginView();
	$lh = new LoginHandler();
	$lc = new LoginController();
	session_start();
		
/*
 * MasterControl
 */
if (!isset($_GET['control'])) {
	$_GET['control'] = "login";
}
if (isset($_GET['action'])) {
	if (($_GET['action']) == "delete") {
		$rh = new RegisterHandler();
		$lw = new LoginView();
		$lh = new LoginHandler();
		$rh->RemoveFromDB($lh->WhoIsLoggedOn());
		$lh->DoLogout();
		$lw->DeleteCookie();
		header('Location: /lab3/index.php');	
	}
}
//TODO Ta bort sträng beroende genom vyer och konstanter
switch($_GET['control']) {
	case "login":
		$control = new LoginController();
		break;
	case "register":
		$control = new RegisterController();
		break;
	default:
		$control = new LoginController();
		break;
}		
		
$tmp = $control->DoControll();

?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sv" lang="sv">

<head>

    <title>	<?php
	echo $tmp->m_title;
	?></title>

    <meta http-equiv="content-type" content="text/html;charset=utf-8" />

</head>

<body>
	<?php

	echo $tmp->m_body;

	?>
</body>

</html>